<?php require('../admin/connexion.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Installation de FujiCraft</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta http-equiv="content-language" content="fr,en" />
        <link rel='shortcut icon' type="image/x-icon" href='./images/favicon.ico' />
        <link rel="stylesheet" type="text/css" href="../css/style.css" title="" media="all" />       
        <link rel="stylesheet" type="text/css" href="../css/register.css" title="" media="all" />
    </head>
    <body>
        <div id="block">
            <div id="contentblock">
                <div class="wrapper">
                    <div class="header">
                        <div class="headerbg">
                            <div class="wrapper">
                                <div class="logo transparent"><a href="./"></a></div>
                            </div>
                        </div>
                    </div>
                    <div class="mainmenu">
                        <div class="wrapper">
                            <div class="left content mainlinks"></div>
                            <div class="clear"></div>
                        </div>
                    </div>
                    <div class="mainbox">
                        <h2>Installation de FujiCraft [Version : <?php echo $version; ?>]</h2>
                        <div class="centre">
                            <?php
                            if (isset($_POST['save'])) {
                                $sitename_edit = $_POST['sitename'];
                                $extension_edit = $_POST['extension'];
                                $forum_edit = $_POST['forum'];
                                $map_edit = $_POST['map'];
                                $forum_edit = $_POST['forum'];
                                $live_edit = $_POST['live'];
                                $youtube_edit = $_POST['youtube'];
                                $facebook_edit = $_POST['facebook'];
                                $minecraft_ip_edit = $_POST['minecraft_ip'];
                                $minecraft_port_edit = $_POST['minecraft_port'];
                                $minecraft_version_edit = $_POST['minecraft_version'];
                                $bukkit_edit = $_POST['bukkit'];
                                $ts_ip_edit = $_POST['ts_ip'];
                                $ts_port_edit = $_POST['ts_port'];
                                $mumbles_ip_edit = $_POST['mumble_ip'];
                                $mumble_port_edit = $_POST['mumble_port'];
                                $date_site_edit = date('Y') . "-" . date('m') . "-" . date('j');
                                $date_server_edit = $_POST['annee'] . "-" . $_POST['mois'] . "-" . $_POST['jour'];

                                $query = "INSERT " . $database . "." . $tb_info . " SET sitename_info = '$sitename_edit', extension_info = '$extension_edit', putonline_info = '$date_site_edit', forum_info = '$forum_edit', dynmap_info = '$map_edit', live_info = '$live_edit', youtube_info = '$youtube_edit', facebook_info = '$facebook_edit', serverip_info = '$minecraft_ip_edit', serverport_info = '$minecraft_port_edit', serverversion_info = '$minecraft_version_edit', bukkitversion_info = '$bukkit_edit', serverputonline_info = $date_server_edit, tsip_info = '$ts_ip_edit', tsport_info = '$ts_port_edit', mumbleip_info = '$mumbles_ip_edit', mumbleport_info = ' $mumble_port_edit', annonce_choix_info = 'Non', annonce_texte_info = '', maintenance_choix_info = 'Non', maintenance_texte_info = '' ";
                                mysql_query($query) OR DIE(mysql_error());
                                ?>
                                <div id="box" onclick="document.getElementById('box').style.display='none';" class="success-box rounded" title="Fermer la fen&ecirc;tre">
                                    Les informations on bien &eacute;t&eacute; enregistr&eacute;es.
                                </div>
                                <br />
                                <br />
                                <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=plugin" class="btn">Passer &agrave; la suite</a> <br />
                                <br />
                                <br />
                                <?php
                            } else if (@$_GET['action'] == "plugin") {
                                if (isset($_POST['setplugin'])) {
                                    $datalog = $_POST['datalog'];
                                    $iconomy = $_POST['iconomy'];
                                    $jobs = $_POST['jobs'];
                                    $dynmap = $_POST['dynmap'];

                                    $query = "INSERT " . $database . "." . $tb_plugins . " SET datalog_plg = '$datalog', iconomy_plg = '$iconomy', jobs_plg = '$jobs', dynmap_plg = '$dynmap' ";
                                    mysql_query($query) OR DIE(mysql_error());
                                    ?>
                                    <div id="box" onclick="document.getElementById('box').style.display='none';" class="success-box rounded" title="Fermer la fen&ecirc;tre">
                                        Les informations ont bien &eacute;t&eacute; enregistr&eacute;es.
                                    </div>
                                    <br />
                                    <br />
                                    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=account" class="btn">Passer &agrave; la suite</a> <br />
                                    <br />
                                    <br />
                                    <?php
                                } else {
                                    ?>
                                    <h3>Informations</h3>
                                    Veuillez choisir entre "Oui" ou "Non" si vous possèdez ce plugins ou non. Cela affectera le panneau d'administration. <br />
                                    <br />
                                    <h3>Choix des plugins</h3>
                                    <br />
                                    <form method="post" action="">
                                        <table border="0" cellspacing="0">
                                            <tr>
                                                <td colspan="3" class="title_form">Plugins utilis&eacute;s</td>
                                            </tr>
                                            <tr>
                                                <td class="text_form"><a href="http://plugins.bukkit.org/#ti=datalog&ta=all&au=&subm=false" title="T&eacute;l&eacute;charger DataLog">DataLog :</a> </td>
                                                <td>
                                                    <select name="datalog">
                                                        <option>Non</option>
                                                        <option>Oui</option>
                                                    </select>
                                                    <i class="px10">(Conseill&eacute;)</i>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="text_form"><a href="http://plugins.bukkit.org/#ti=iconomy&ta=all&au=&subm=false" title="T&eacute;l&eacute;charger iConomy">iConomy :</a> </td>
                                                <td>
                                                    <select name="iconomy">
                                                        <option>Non</option>
                                                        <option>Oui</option>
                                                    </select>
                                            </tr>
                                            <tr>
                                                <td class="text_form"><a href="http://plugins.bukkit.org/#ti=jobs&ta=all&au=&subm=false" title="T&eacute;l&eacute;charger Jobs">Jobs :</a> </td>
                                                <td>
                                                    <select name="jobs">
                                                        <option>Non</option>
                                                        <option>Oui</option>
                                                    </select>
                                                    <i class="px10">(Pas encore fonctionnel)</i>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="text_form"><a href="http://plugins.bukkit.org/#ti=dynmap&ta=all&au=&subm=false" title="T&eacute;l&eacute;charger Dynmap">Dynmap :</a> </td>
                                                <td>
                                                    <select name="dynmap">
                                                        <option>Non</option>
                                                        <option>Oui</option>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" valign="middle" align="center"><input type="submit" name="setplugin" value="Envoyer" class="btn" /></td>
                                            </tr>
                                        </table>
                                        <br />
                                    </form>
                                    <?php
                                }
                            } else if (@$_GET['action'] == "account") {
                                if (isset($_POST['create'])) {
                                    if (($_POST['login'] == "") || ($_POST['pass'] == "") || ($_POST['email'] == "") || ($_POST['prenom'] == "") || ($_POST['nom'] == "")) { // si login ou mot de passe non sp�cifi�s >> message d'erreur
                                        ?>
                                        <div id="box" onclick="document.getElementById('box').style.display='none';" class="error-box rounded" title="Fermer la fen&ecirc;tre">
                                            Echec d'enregistrement. Tout les champs ne sont pas remplis.
                                        </div>
                                        <br />
                                        <br />
                                        <a href="<?php echo $_SERVER['PHP_SELF'] ?>?action=next" class="btn">Retour</a> <br />
                                        <?php
                                    } else {
                                        if ($_POST['pass'] == $_POST['pass2']) { // on v�rifie si le mot de passe et le mot de passe confirm� ont la m�me valeur
                                            $_POST['login'] = htmlspecialchars($_POST['login']); // On rend inoffensives les balises HTML que le visiteur a pu rentrer
                                            $_POST['nom'] = htmlspecialchars($_POST['nom']);
                                            $_POST['prenom'] = htmlspecialchars($_POST['prenom']);
                                            if (preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['email'])) {
// on passe toutes les variables $POST en variables
                                                $login = mysql_escape_string($_POST['login']);
                                                $pass = md5($_POST['pass']); // ici, on crypte le mot de passe � l'aide de MD5 (c'est tout simple non ? :)
                                                $pass_no_md5 = $_POST['pass'];
                                                $nom = mysql_escape_string($_POST['nom']);
                                                $prenom = mysql_escape_string($_POST['prenom']);
                                                $email = mysql_escape_string($_POST['email']);
                                                $date_inscription = date('y') . "-" . date('m') . "-" . date('j');
                                                // on fait l'INSERT dans la base de donn�es
                                                $add_user = sprintf("INSERT INTO " . $database . "." . $tb_utilisateurs . " (login, pass, pass_no_md5, nom, prenom, email, privilege, date_inscription) VALUES ('$login', '$pass', '$pass_no_md5', '$nom', '$prenom', '$email','admin', '$date_inscription')");
                                                mysql_select_db($database, $dbconnect);
                                                $result = mysql_query($add_user, $dbconnect) or die(mysql_error());
                                                ?>
                                                <div id="box" onclick="document.getElementById('box').style.display='none';" class="success-box rounded" title="Fermer la fen&ecirc;tre">
                                                    Enregistrement r&eacute;ussi.
                                                </div>
                                                <br />
                                                <br />
                                                <a href="<?php echo $_SERVER['PHP_SELF'] ?>?action=finish" class="btn">Suivant</a> <br />
                                                <?php
                                            } else {
                                                ?>
                                                <div id="box" onclick="document.getElementById('box').style.display='none';" class="error-box rounded" title="Fermer la fen&ecirc;tre">
                                                    L'email entr&eacute; est incorrect. V&eacute;rifiez que vous n'avez pas fait d'erreur.
                                                </div>
                                                <br />
                                                <br />
                                                <a href="<?php echo $_SERVER['PHP_SELF'] ?>?action=next" class="btn">Retour</a> <br />
                                                <?php
                                            }
                                        } else {
                                            ?>
                                            <div id="box" onclick="document.getElementById('box').style.display='none';" class="error-box rounded" title="Fermer la fen&ecirc;tre">
                                                Echec d'enregistrement. Tout les champs ne sont pas remplis.
                                            </div>
                                            <br />
                                            <br />
                                            <a href="<?php echo $_SERVER['PHP_SELF'] ?>?action=account" class="btn">Retour</a> <br />
                                            <?php
                                        }
                                    }
                                } else {
                                    ?>
                                    <h3>Informations</h3>
                                    Maintenant que les configurations de bases ont &eacute;t&eacute; entr&eacute;es, nous allons cr&eacute;er le compte administrateur. <br />
                                    <br />
                                    <h3>Compte administrateur</h3>
                                    Tout les champs doivent &ecirc;tre remplies. <br />
                                    <br />
                                    <form method="post" action="">
                                        <table border="0" cellspacing="0">
                                            <tr>
                                                <td colspan="3" class="title_form">Vos informations</td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Nom : </td>
                                                <td><input type="text" name="nom" size="30" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Pr&eacute;nom : </td>
                                                <td><input type="text" name="prenom" size="30" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Adresse e-mail : </td>
                                                <td><input type="text" name="email" size="30" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td colspan="3" class="title_form">Votre profil</td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Pseudo : </td>
                                                <td><input type="text" name="login" size="30" class="border" title="Attention ! Ceci sera votre login." /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Mot de passe :</td>
                                                <td><input type="password" name="pass" size="30" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">R&eacute;p&eacute;tez le mot de passe : </td>
                                                <td><input type="password" name="pass2" size="30" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" valign="middle" align="center"><input type="submit" name="create" value="Cr&eacute;er" class="btn" /></td>
                                            </tr>
                                        </table>
                                        <br />
                                    </form>
                                    <?php
                                }
                            } else if (@$_GET['action'] == "finish") {
                                ?>
                                <h3>Compte cr&eacute;&eacute;</h3>
                                Votre compte administrateur a bien &eacute;t&eacute; cr&eacute;&eacute;. Vous pouvez d&egrave;s maintenant l'utiliser. <br />
                                <br />
                                <h3>Fin de l'installation</h3>
                                <b>Bravo ! Vous avez termin&eacute; l'installation.</b> <br />
                                <br />
                                Vous devez maintenant supprimer le dossier "<b>install/</b>". Faites-le, sinon n'importe qui pourra facilement vous hacker.<br />
                                <br />
                                <br />
                                <a href="../" class="btn">Voir le site</a>&nbsp;<a href="../admin/" class="btn">Allez au Panneau d'Administration</a> <br />
                                <?php
                            } else {
                                ?>
                                <h3>Informations</h3>
                                <b>Bienvenue dans l'installation automatis&eacute;e & suivie de FujiCraft.</b> <br />
                                <br />
                                Nous allons maintenant installer pas &agrave; pas votre site. Pour cela, veuillez remplir les formulaires qui suivront. <br />
                                <br />
                                <h3>Configuration de base</h3>
                                <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>">
                                    <table border="0" cellspacing="0">
                                        <tr>
                                            <td colspan="3" class="title_form">Informations du site</td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Nom : </td>
                                            <td><input type="text" name="sitename" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Extension : </td>
                                            <td><input type="text" name="extension" size="30" class="border" /> <b class="px8">(Exemple : .com, .fr, .ch)</b></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Forum : </td>
                                            <td><input type="text" name="forum" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Dynmap : </td>
                                            <td><input type="text" name="map" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Live : </td>
                                            <td><input type="text" name="live" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">YouTube : </td>
                                            <td><input type="text" name="youtube" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Groupe Facebook : </td>
                                            <td><input type="text" name="facebook" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" class="title_form">Serveur Minecraft</td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Ip du serveur : </td>
                                            <td><input type="text" name="minecraft_ip" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Port du serveur : </td>
                                            <td><input type="text" name="minecraft_port" size="30" value="25565" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Version du serveur : </td>
                                            <td><input type="text" name="minecraft_version" size="30" value="1.7.3" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Version de CraftBukkit : </td>
                                            <td><input type="text" name="bukkit" size="30" value="1000" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">En ligne depuis le : </td>
                                            <td>
                                                <?php
                                                echo "\n\t\t<select name='jour'>";
                                                for ($jour = 1; $jour <= 31; $jour++) {
                                                    if ($jour < 10) {
                                                        echo "\n\t\t\t<OPTION value=$jour name='jour_debut'\">0$jour</OPTION>";
                                                    } else {
                                                        echo "\n\t\t\t<OPTION value=$jour name='jour_debut'\">$jour</OPTION>";
                                                    }
                                                }
                                                echo "\n\t\t</select>";
                                                echo "\n\t\t<select name='mois'>";
                                                for ($mois = 1; $mois <= 12; $mois++) {
                                                    if ($mois < 10) {
                                                        echo "\n\t\t\t<OPTION value=$mois name='mois_debut'\">0$mois</OPTION>";
                                                    } else {
                                                        echo "\n\t\t\t<OPTION value=$mois name='mois_debut'\">$mois</OPTION>";
                                                    }
                                                }
                                                echo "\n\t\t</select>";
                                                echo "\n\t\t<select name='annee'>";
                                                for ($annee = 2009; $annee <= date('Y'); $annee++) {
                                                    echo "\n\t\t\t<OPTION value=$annee name='annee_debut'>$annee</OPTION>";
                                                }
                                                echo "\n\t\t</select>";
                                                ?>
                                                <i class="px10">(Jour / Mois / Ann&eacute;e)</i>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" class="title_form">Serveur vocal</td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Ip TeamSpeak : </td>
                                            <td><input type="text" name="ts_ip" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Port TeamSpeak : </td>
                                            <td><input type="text" name="ts_port" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Ip Mumble : </td>
                                            <td><input type="text" name="mumble_ip" size="30"  class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td class="text_form">Port Mumble : </td>
                                            <td><input type="text" name="mumble_port" size="30" class="border" /></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" valign="middle" align="center"><input type="submit" name="save" value="Enregistrer" class="btn" /></td>
                                        </tr>
                                    </table>
                                </form>
                                <?php
                            }
                            ?>
                        </div>
                    </div>
                </div>
            </div> 
        </div>
    </body>
</html>
